<?php

class Admin_Form_Linkuteis extends Zend_Form
{
    public function init() {
   	    
        $front = Zend_Controller_Front::getInstance();
        $controller = $front->getRequest()->getControllerName();
        $module = $front->getRequest()->getModuleName();
        $url = $front->getBaseUrl().'/'.$module.'/'.$controller;
        $urlbase = $front->getBaseUrl();
        
        $db = Zend_Db_Table_Abstract::getDefaultAdapter();
        
        $this->setName('form_pdr');
        
        $id = $front->getRequest()->getParam('id', 0);
        
        $el = new Zend_Form_Element_Hidden('LNK_ID',array('disableLoadDefaultDecorators' =>true));
        $el->addDecorators(array(array('ViewHelper'),array('Errors')))
            ->addFilter('Int');
        $this->addElement($el);
       
        
        $el = new Zend_Form_Element_Text('LNK_NOM');
        $el->setLabel('Descrição')->setRequired(true)
        ->addFilters(array('StripTags','StringTrim'))
        ->addValidator('NotEmpty');
        $el->setAttrib('required','');
        $this->addElement($el);
        
        $el = new Zend_Form_Element_Text('LNK_URL');
        $el->setLabel('Link')->setRequired(true)
        ->addFilters(array('StripTags','StringTrim'))
        ->addValidator('NotEmpty');
        $el->setAttrib('required','');
        $this->addElement($el);
        

        $el = new Zend_Form_Element_Text('LNK_ORD');
        $el->setLabel('Ordem')->setRequired(true)
        ->addFilters(array('StripTags','StringTrim'))
        ->addValidator('NotEmpty');
        $el->setAttrib('required','');
        $this->addElement($el);
        
        /*
        $img = glob('public/upload/'.$controller.'/'.$front->getRequest()->getParam('id').'.*');
        foreach($img as $src) {
            $el = new Zend_Form_Element('img',array( 'helper'=>'formNote', 'value'=>'<img src="'.$front->getBaseUrl().'/'.$src.'" />' ));
            $this->addElement($el);
        }
        
        $el = new Zend_Form_Element_File('LNK_FILE'); 
        $el->setLabel('Imagem')
	->addValidator('Extension', false, array('jpg', 'png', 'gif'));
        $this->addElement($el);
        */
        
        $el = new Zend_Form_Element_Checkbox('LNK_STA',array('checked'=>'checked'));
        $el->setLabel('Status');
        $this->addElement($el);
        
        $btn = new Zend_Form_Element_Submit('Salvar',array('disableLoadDefaultDecorators' =>true));
        $btn->addDecorators(array(array('ViewHelper'),array('Errors')));
        $btn->setLabel('Salvar');
        $btn->setAttrib('id', 'submitbutton');
        $btn->setAttrib('class', 'btn-frm');
        $this->addElement($btn);
        
        $btn = new Zend_Form_Element_Button('Cancelar',array('disableLoadDefaultDecorators' =>true));
        $btn->setDecorators(array(array('Description', array('escape' => false, 'tag' => false))));
        $btn->setDescription('<a href="'.$url.'" class="btn-frm">Voltar</a>');
        $btn->setAttrib('id', 'btncancel');
        $btn->setAttrib('class', 'btn-frm');
        $this->addElement($btn);
        
        
    }

}

